""" System imports """
import logging
from pygame.locals import *
from character import Character

""" Equinox """
from events import *

""" Constants """


""" Set up logging """
_log = logging.getLogger("equinox.player")


class Player(object):
    """ A player is the physical player siting in the chair. 
    @see Character"""
    def __init__(self, evManager):
        self.evManager = evManager
        self.game = None
        self.name = ""
        self.evManager.registerListener( self )
        
        self.characters = [ Character(evManager) ]

    #----------------------------------------------------------------------
    def __str__(self):
        return '<Player %s %s>' % (self.name, id(self))


    #----------------------------------------------------------------------
    def notify(self, event):
        if isinstance(event, TickEvent):
            pass
        elif isinstance(event, KeyPressedEvent):
            if event.key == K_UP:
                ev = CharacterMoveRequest(DIRECTION_UP)
                self.evManager.post(ev)
            elif event.key == K_DOWN:
                ev = CharacterMoveRequest(DIRECTION_DOWN)
                self.evManager.post(ev)
            elif event.key == K_LEFT:
                ev = CharacterMoveRequest(DIRECTION_LEFT)
                self.evManager.post(ev)
            elif event.key == K_RIGHT:
                ev = CharacterMoveRequest(DIRECTION_RIGHT)
                self.evManager.post(ev)